<template>
  <div id="login">
      <yd-cell-group>
          <yd-cell-item arrow type="label" v-show="isJT">
              <span slot="left">公司名称&nbsp;&nbsp;&nbsp;&nbsp;</span>
              <select slot="right" v-model="company">
                  <option value="">请选择公司名称</option>
                  <option :value="c" v-for="(c,key) in companylist" :key="key">{{c}}</option>
              </select>
          </yd-cell-item>
           <yd-cell-item arrow type="label">
              <span slot="left">统计类别&nbsp;&nbsp;&nbsp;&nbsp;</span>
              <select slot="right" v-model="type" @change="typeStyle">
                  <option value="">请选择统计类别</option>
                  <option :value="t" v-for="(t,key) in typelist" :key="key">{{t}}</option>
              </select>
          </yd-cell-item>
      </yd-cell-group>
      <div class="checkBlock">
        <yd-button size="large" @click.native="login" class="checkBtn" shape="circle">查询</yd-button>
      </div>
  </div>
</template>

<script>
export default {
  name: 'login',
  data(){
      return{
         companylist:[],
         typelist:['各年度面积统计','每日收费统计表','综合信息统计表','银行对账统计表'],
         company:'',
         type:'' ,
         isJT:false //集团开关
      }
  },
  methods:{
    getpersoninfo(userid,agentid){
      let data = {
        method:'getpersoninfo',
        userid:userid,
        agentid:agentid,
        isweixin:1
      }
      this.$dialog.loading.open("稍等片刻...");
      this.axios.post('https://qy.heatingpay.com/weixinservice.ashx',data).then(res=>{
        this.$dialog.loading.close();
        if(res[0].companyname == '盘锦广田热电集团'){
          this.isJT = true;
          this.companylist = ['盘锦广田热电有限公司','盘锦热电有限责任公司','盘锦双台子热力有限公司','盘锦汇融热力有限公司']
        }else{
          this.company = res.companyname
        }
      })
    },
    typeStyle(){
      if(this.type == '每日收费统计表'){
        this.chartlist = [];
        this.chartlist = ['当日：年度占比','当日：结算方式','各分公司收入情况','收入分析（当月累计）','本年收费完成率']
      }else if(this.type == '各年度面积统计'){
        this.chartlist = [];
        this.chartlist = ['饼形图','各年度面积分析','各所站面积分析']
      }else if(this.type == '综合信息统计表'){
        this.chartlist = [];
        this.chartlist = ['饼形图','历史欠费分析']
      }else{
        this.chartlist = [];
      }
    },
    login(){
      if(this.company == ''){
        this.$dialog.alert({mes: '公司名称不能为空'});
      }else if(this.type == ''){
        this.$dialog.alert({mes: '统计类别不能为空'});
      }else{

        sessionStorage.type = this.type;
        sessionStorage.company = this.company;
        if(this.type != '银行对账统计表'){
          this.$router.push('/chart')
        }else{
          this.$router.push('/table')
        }  
      }
    }
  },
  created(){
    this.getpersoninfo(this.$route.query.userid,this.$route.query.agentid)
  }
}
</script>

<style>
.checkBlock{
  padding: 0 20px
}
.checkBtn{
  background: #26a2ff !important
}
.yd-btn-primary:active{
  background: #69b0e4 !important
}
</style>
